All Questions
Tagged with ruby-on-railsunit-testing
17 questions
1vote
1answer
38views
Optimize Tests in Rails6 - Minitest - Factory
I finally got this working but I am concerned I am being 'too' specific in my tests, and also that I am repeating myself a significant amount. I could also combine all of the failures into a single ...
2votes
0answers
84views
TDD for Ruby On Rails API for group event items
I found myself working in this coding exercise for a work offer. I tried to apply TDD in the process but I didn't get any feedback from the company and I really would like to know what can be improved ...
2votes
0answers
997views
Rails CRUD feature specs (RSpec and Capybara)
The following feature spec tests CRUD operations for the users resource in a Rails 4.2.8 application. It includes tests for filtering, sorting and pagination ...
4votes
1answer
2kviews
Rails & RSpec - Testing API with request specs and shared examples
I have written the following shared examples which are used in multiple request specs to test a namespaced RESTful JSON API. Application details: Rails 4.2, RSpec 3.5, Devise for authentication and ...
3votes
1answer
631views
Controller tests (Rails 4.2 and RSpec 3.5)
The following code is a controller spec used in a Rails 4.2 application with RSpec 3.5. I would greatly appreciate your suggestions on how to improve it (e.g., efficiency, readability, maintainability,...
8votes
2answers
241views
Error-testing be with cucumber/capybaraweb
I'm working on writing tests for a rails application using cucumber and capybara. I have a scenario for a user editing a post, and making it invalid. The scenario looks like this: ...
1vote
1answer
59views
Mini Test testing save on one and many trips
I know there is a balance to be struck between writing dry code and damp code but I have the feeling that this is a bit too repeative. Is there a terse yet self explainatory way to rewrite these tests?...
5votes
1answer
392views
Rspec - testing basic functionality - redundant testing?
Being pretty new to testing, I was wondering how many of these tests make sense. restaurants_controller_spec.rb ...
0votes
2answers
398views
Testing a simple guard clause in isolation
I’m using decorator objects in a Rails app so that I don’t have to do nil? checks in views. Everything is working nicely and it’s easy to test, but I’m suspicious ...
1vote
1answer
1kviews
Add existing models to a relation using nested attributes
I needed to add existing models to a has-many relation using nested attributes so I overwrote thumbnails_attributes=: ...
1vote
1answer
3kviews
Testing after_save hooks in Rails 4.2 with MiniTest
I've recently started working on a new application in Rails 4.2.0-beta2. I've been using this as an opportunity to learn more about MiniTest, with a stretch goal of being as strict with myself with ...
4votes
2answers
778views
RSpec tests for a cash flow model
This is my first model RSpec test: ...
2votes
1answer
199views
Using RSpec subject to setup a test
I find myself using subject blocks in my tests to setup example because it is succinct. However is this considered bad form and can it have undesired consequences? ...
2votes
1answer
211views
Test for a Rails app
Here's a test from a Rails app I'm working on. I want to know if I'm using describe, let, ...
1vote
1answer
567views
Refactoring my controller specs
In my project, I have this kind of code to test my controllers: ...